<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>${title}</title>
<%@include file="/WEB-INF/templates/common/common.jsp"%>
 <script type="text/javascript" src="${basePath}/static/jqPaginator/jqPaginator.js"></script>
</head>
<body>

	<!--头部-->
	<%@include file="/WEB-INF/templates/common/header.jsp"%>
	<!------导航条-->
	<%@include file="/WEB-INF/templates/common/navigation.jsp"%>

	<div class="list_main lay_out">
		<div class="list_DH">
			<%@include file="/WEB-INF/templates/common/printnav.jsp"%>
		</div>
		<div class="list_NR">
			<div class="loc">
				<h3>扫描查看</h3>
			</div>
			<div class="list_con_table">
			<div class="search_table">
                <ul class="clearfix" style="margin-bottom:0;">
                       <li class="Label_1">姓名：&nbsp;</li>
				    <li class="Label_2"><input class="input_box" type="text"  name='' id='name' value='' /></li>
				    <li class="Label_1">识别码：&nbsp;</li>
				    <li class="Label_2"><input class="input_box" type="text"  name='' id='mrId' value='' /></li>
				    <li class="Label_1">身份证：&nbsp;</li>
				    <li class="Label_2"><input class="input_box" type="text"  name='' id='idCard' value='' /></li>
				    <li class="Label_1">出院日期：&nbsp;</li>
				    <li class="Label_2"><input class="input_box" style="width:40%" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"  name='' id='outHospitalStartTime' value='' />&nbsp;-&nbsp;<input class="input_box" style="width:40%" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"  name='' id='outHospitalEndTime' value='' /></li>
				    <li class="Label_1">出院科室：&nbsp;</li>
				    <li class="Label_2" >
				    <select id="outHospitalOfficeId" class="input_box">
				    	<option value="0">请选择</option>
				    	<c:forEach items="${officeList}" var="office">
				    		<option value="${office.id}">${office.name}</option>
				    	</c:forEach>
				    
				    </select></li>
				     <li class="Label_1">性别：&nbsp;</li>
				    <li class="Label_2">
				    <select id="sexId" class="input_box">
				    	<option value="0">请选择</option>
				    	<c:forEach items="${sexes}" var="sex">
				    		<option value="${sex.id}">${sex.name}</option>
				    	</c:forEach>
				    
				    </select></li>
				        <li class="Label_1" style="height:78px;line-height:78px;">离院方式：&nbsp;</li>
				    <li class="Label_2" style="width:86.5%;height:78px;padding-top:10px;text-align:left;">
				    <c:forEach items="${outHospitalList}" var="outHospitalType">
				     <input type="checkbox" class="check_cl"  name='outHospitalType' value='${outHospitalType.id}' />${outHospitalType.name }
				     </c:forEach>
				     <input class="btn_qx" type="button"  name='' onclick="selectAll()" value='全选' />
				     <input class="btn_qx" type="button"  name='' id='' onclick="disableAll()" value='取消' />
				    </li>
                    <li class="Label_5">
                        <a onclick="init()">查询</a>  
                    </li>
                  
                </ul>
            </div> 
		<table style="width:934px; float:left; border-collapse:collapse;" cellpadding="0" cellspacing="0">
	      <tr>
	      <td class="tdLabel_4">识别码</td>
	      <td class="tdLabel_4">姓名</td>
	      <td class="tdLabel_4">身份证</td>
	      <td class="tdLabel_4">出院科室</td>
	      <td class="tdLabel_4">出院时间</td>
	      <td class="tdLabel_4">离院方式</td>
	      <td class="tdLabel_4">操作</td>
	      </tr>
	      <tbody id="tbody"></tbody>
	     </table>
		</div>
		<!-- 	<div class="pageList">
               <ul class="pagination clearfix" id="page_plus"></ul>
		       <div class="pagination">
		            <div>总共：<b id="totalPage">0</b> 条信息    当前页是第 <b id="currentPage">0/0</b>　页</div>
		       </div>          
		    </div> -->
		</div>
	</div>
	<!------页脚部分-->
	<%@include file="/WEB-INF/templates/common/footer.jsp"%>
	
	
	<!-- JS -->
	<script type="text/javascript">
	
	function init(pageNo,pageSize){
		
		var name=$("#name").val();
		var sexId=$("#sexId").val();
		var idCard=$("#idCard").val();
		var outHospitalStartTime=$("#outHospitalStartTime").val();
		var outHospitalEndTime=$("#outHospitalEndTime").val();
		var mrId=$("#mrId").val();
		var outHospitalOfficeId=$("#outHospitalOfficeId").val();
		var outHospitalTypeIds=[];
		outHospitalTypeIds=getFormVals("outHospitalType");
	  // alert(outHospitalTypeIds);
		console.log("name="+name+"---sexId="+sexId+"---idCard="+idCard+"--mrId="+mrId+"--outHospitalStartTime="+outHospitalStartTime+"---outHospitalEndTime="+outHospitalEndTime+"---outHospitalOfficeId="+outHospitalOfficeId+"---outHospitalTypeIds="+outHospitalTypeIds);
		jQuery.support.cors = true;
		$.ajax({
			type:'get',
			url:"${corePath}/statis/selectScanMedicalRecordListAjax",
			data:{name:name,idCard:idCard,mrId:mrId,sexId:sexId,outHospitalStartTime:outHospitalStartTime,outHospitalEndTime:outHospitalEndTime,outHospitalOfficeId:outHospitalOfficeId,outHospitalTypeIds:outHospitalTypeIds
				 },
			success:function(data){
			
				console.log(data);
				if(data.success){
					var hospitalNotes=data.data;
					var len=hospitalNotes.length;
					if(len>0){
						var html='';
	    				for(var i=0;i<len;i++){
	    					var obj=hospitalNotes[i];
	    					html+="<tr>"+
		    	                  "  <td class='tdLabel_5'>"+(obj.mrId==undefined?'':obj.mrId)+"</td>"+
		    	                  "  <td class='tdLabel_5'>"+(obj.name==undefined?'':obj.name)+"</td>"+
		    	                  "  <td class='tdLabel_5'>"+(obj.id_number==undefined?'':obj.id_number)+"</td>"+
		    	                  "  <td class='tdLabel_5'>"+(obj.officeName==undefined?'':obj.officeName)+"</td>"+
		    	                  "  <td class='tdLabel_5'>"+(obj.outHospitalDate==undefined?'':obj.outHospitalDate)+"</td>"+
		    	                  "  <td class='tdLabel_5'>"+(obj.outHospitalType==undefined?'':obj.outHospitalType)+"</td>"+
		    	                  "  <td class='tdLabel_5'><a class='int' target='_blank' href='${corePath}/medrecord/showMedrecordImage?firstGuid="+obj.guid+"'>查看</a></td>"+
		    	                  "</tr>";
	    					
	    				}
	    				
	    				$("#tbody").html("").html(html);
					}else{
			            layer.alert('查询数据为空！',{icon:5});
						$("#tbody").html("");
						$("#currentPage").html("0/0");
						$("#totalPage").html("0");
						$("#page_plus").html("");
					}
				}else{
					layer.alert(data.msg,{icon:5});
					$("#tbody").html("");
					$("#currentPage").html("0/0");
					$("#totalPage").html("0");
					$("#page_plus").html("");
				}
			}
		})
	}
		

	//获取checkbox值
	function getFormVals(name){
		var arr = [];
		$("input[type='checkbox'][name='"+name+"']:checked").each(function(){
				arr.push($(this).val());	

		});
		return arr.toString();
	}


	function selectAll(){
		  $('input[name="outHospitalType"]').each(function(){  
	          //此处如果用attr，会出现第三次失效的情况  
	          $(this).prop("checked",true);  
	      });  
	}

	function disableAll(){
		  $('input[name="outHospitalType"]').each(function(){  
	          //此处如果用attr，会出现第三次失效的情况  
	          $(this).prop("checked",false);  
	      });  
	}
		
		//跳转至图片扫描
		function searchScan(obj){
			var idNumber=$(obj).attr("idNumber");
			var folderName=$(obj).attr("firstGuid");
			var mrId=$(obj).attr("mrId");
			var scanId=$(obj).attr("scanId");
			var scanStatus=$(obj).attr("scanStatus");

			window.open("${basePath}/scan/searchScan?folderName="+folderName+"&scanId="+scanId+"&scanStatus="+scanStatus+"&mrId="+mrId+"&idNumber="+idNumber,
	 				'_blank',
	 				"toolbar=yes,resizable=1, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=yes, width=800, height=600"); 
			} 
	</script>
</body>
</html>
<%-- <%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>北京胡桃健康医疗</title>
<%@include file="/WEB-INF/templates/common/common.jsp"%>
 <script type="text/javascript" src="${basePath}/static/jqPaginator/jqPaginator.js"></script>
</head>
<body>

	<!--头部-->
	<%@include file="/WEB-INF/templates/common/header.jsp"%>
	<!------导航条-->
	<%@include file="/WEB-INF/templates/common/navigation.jsp"%>

	<div class="list_main lay_out">
		<div class="list_DH">
			<%@include file="/WEB-INF/templates/common/printnav.jsp"%>
		</div>
		<div class="list_NR">
			<div class="loc">
				<h3>文档扫描</h3>
			</div>
			<div class="list_con_table">
			<div class="search_table">
                <ul class="clearfix" style="margin-bottom:0;">
                    <li class="Label_1">识别码：&nbsp;</li>
                    <li class="Label_2"><input class="input_box" type="text"  name='mrId' id='mrId' value='${params.mrId}' /></li>
                    <li class="Label_1">姓名：&nbsp;</li>
                    <li class="Label_2"><input class="input_box" type="text"  name='name' id='name' value='${params.name}' /></li>
                    <li class="Label_1">出院科室：&nbsp;</li>
                    <li class="Label_2">
                        <select id="outDeptId" name="outDeptId" style="width:100%;height:30px">
                    		<option value="">请选择科室：</option>
                    		<c:forEach items="${officeList}" var="office">
                    			<option value="${office.id}">${office.name}</option>
                    		</c:forEach>
                    	</select>
                    </li>
                    <li class="Label_1">扫描状态：&nbsp;</li>
                    <li class="Label_2">
                    	 <input type="radio" class="radio_cl" name='isScan' id='' checked value='1' />未扫描&nbsp;&nbsp;
     					 <input type="radio" class="radio_cl" name='isScan' id='' value='2' />已扫描
                    </li>
                    <li class="Label_1">出院日期：&nbsp;</li>
                    <li class="Label_4"><input class="input_box" style="width:150px;" type="text"  name='startTime' id='startTime' value='${params.startTime}' onFocus="WdatePicker()" /><span>&nbsp;-&nbsp;</span><input class="input_box" type="text" style="width:150px;"  name='endTime' id='endTime' value='${params.endTime}' onFocus="WdatePicker()" /></li>
                    <li class="Label_5">
                        <a onclick="searchQua(0,20)">查询</a>  
                    </li>
                  
                </ul>
            </div> 
				<table class="Search_tableList" cellpadding="0" cellspacing="0">
					<tr>
						<td class="tdLabel_4">序号</td>
	                    <td class="tdLabel_4">识别码</td>
	                    <td class="tdLabel_4">姓名</td>
	                    <td class="tdLabel_4">证件号码</td>
	                    <td class="tdLabel_4">出院科室</td>
	                    <td class="tdLabel_4">出院时间</td>
	                    <td class="tdLabel_4">操作</td>
					</tr>
					<tbody id="tbody"></tbody>
				</table>
			</div>
			<div class="pageList">
               <ul class="pagination clearfix" id="page_plus"></ul>
		       <div class="pagination">
		            <div>总共：<b id="totalPage">0</b> 条信息    当前页是第 <b id="currentPage">0/0</b>　页</div>
		       </div>          
		    </div>
		</div>
	</div>
	<!------页脚部分-->
	<%@include file="/WEB-INF/templates/common/footer.jsp"%>
	
	
	<!-- JS -->
	<script type="text/javascript">
	
		function searchQua(pageNo,pageSize){
			var startTime=$("#startTime").val();
			var endTime=$("#endTime").val();
			var name=$("#name").val();
			var mrId=$("#mrId").val();
			var isScan=$('input:radio[name="isScan"]:checked').val();
			var outDeptId=$("#outDeptId").val();
			
			$.ajax({
				type:"post",
				url:"${basePath}/scan/getPreScanMsg",
				data:{startTime:startTime,endTime:endTime,name:name,mrId:mrId,outDeptId:outDeptId,status:isScan,pageNo:pageNo,pageSize:pageSize},
				success:function(data){
					var count=data.count;
					var quaList=data.preScanList;
					if(quaList!=null && quaList!="" && quaList!=undefined){
						page(pageNo+1,count);
						var html="";
						for(var i=0;i<quaList.length;i++){
							var obj=quaList[i];
							html+="<tr>"+
			                      "  <td class='tdLabel_5'>"+(parseInt(i)+1)+"</td>"+
				                  "  <td class='tdLabel_5'>"+obj.mrId+"</td>"+
				                  "  <td class='tdLabel_5'>"+obj.name+"</td>"+
				                  "  <td class='tdLabel_5'>"+obj.idNumber+"</td>"+
				                  "  <td class='tdLabel_5'>"+obj.deptName+"</td>"+
				                  "  <td class='tdLabel_5'>"+obj.outDate+"</td>"+
				                  "  <td class='tdLabel_5'><a class='int' firstGuid='"+obj.firstGuid+"' scanId='"+obj.scanId+"'  scanStatus='"+obj.scanStatus+"' mrId='"+obj.mrId+"' name='"+obj.name+"' idNumber='"+obj.idNumber+"'  onclick='searchScan(this)'>扫描</a></td>"+
				                  "</tr>";	
						}
						$("#tbody").html("").html(html);
					}else{
						alert("数据为空!");
						window.location.href="${basePath}/scan/index";
					}	
				}
			})
		}
		
		//分页
		function page(currentPage,totalCounts){
	        var pageSize = 20;
	        var visiblePages = 5;
	        var totalPages = Math.ceil(totalCounts/pageSize);
	        $('#page_plus').jqPaginator({

	            totalCounts: totalCounts,
	            pageSize:pageSize,
	            visiblePages: visiblePages,
	            currentPage: currentPage,

	            first:'<li class="first"><a href="javascript:void(0);">首页</a></li>',
	            prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
	            next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
	            last: '<li class="last"><a href="javascript:void(0);">末页</a></li>',
	            page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
	            onPageChange: function (num,type) {
	            	
	            	 if(type !='init'){
	                 
	            		 searchQua(num-1,pageSize);
	                 }
	            	
	                $("#totalPage").html(totalCounts);
	                $("#currentPage").html(num+"/"+totalPages);
	            }
	        });

	    }
		
		//跳转至图片扫描
		function searchScan(obj){
			var idNumber=$(obj).attr("idNumber");
			var folderName=$(obj).attr("firstGuid");
			var mrId=$(obj).attr("mrId");
			var scanId=$(obj).attr("scanId");
			var scanStatus=$(obj).attr("scanStatus");

			window.open("${basePath}/scan/searchScan?folderName="+folderName+"&scanId="+scanId+"&scanStatus="+scanStatus+"&mrId="+mrId+"&idNumber="+idNumber,
	 				'_blank',
	 				"toolbar=yes,resizable=1, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=yes, width=800, height=600"); 
			} 
	</script>
</body>
</html> --%>